/***
* 防抖
*  @param {Function} fn - 执行事件
*  @param {String} event - 事件类型 例："click"
*  @param {Number} delay - 间隔时间
*/

export default {
  inserted(el, binding) {
    let [fn, event = "click", delay = 300] = binding.value
    let timer
    el.addEventListener(event, () => {
      timer && clearTimeout(timer)
      timer = setTimeout(() => fn(), delay)
    })
  }
}